<?php

namespace App\models;

use Illuminate\Database\Eloquent\Model;

class UserMoneyLog extends Model
{
    protected $guarded = ['id'];
    protected $appends = ['order_code','order_amount','type_txt','money_txt'];
    
    public function user()
    {
    	return $this->belongsTo(User::class);
    }

    public function order()
    {
    	return $this->belongsTo(Order::class);
    }

    public function shop()
    {
    	return $this->belongsTo(Shop::class);
    }

    public function getTypeTxtAttribute()
    {
        return $this->type==1?'收入':'支出';
    }

    

    public function getMoneyTxtAttribute()
    {
        return $this->money/100;
    }

    public function getOrderCodeAttribute()
    {
        return $this->order->code;
    }

    public function getOrderAmountAttribute()
    {
        return $this->order->total_amount;
    }
}
